import 'dart:collection';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../m_chatroom.dart';
import '../../interface/chat_room_leaf_interface.dart';
import '../tools/room_personal_data_page.dart';

class UserListPageModel extends ChatRoomChangeNotifier {
  int initIndex = 1;
  int initCashIndex = 0;

  UserListPageModel(this.initIndex, this.initCashIndex) {
    controller = PageController(initialPage: initIndex);
  }

  @override
  onRootProxyModelCreated() {
    selectItem(initIndex);
  }

  // ChannelUserListRsp? data;

  int currentTabIndex = 0;
  late PageController controller;

  bool isAnimating = false;

  selectItem(int index) {
    currentTabIndex = index;
    isAnimating = true;
    controller.animateToPage(currentTabIndex,
        duration: Duration(milliseconds: 400), curve: Curves.easeInOut);
    notifyListeners();
  }

  selectItemWithIndex(int index) {
    if (isAnimating) {
      if (index == currentTabIndex) {
        isAnimating = false;
      }
    } else {
      currentTabIndex = index;
      notifyListeners();
    }
  }

  // onItemPressed(BuildContext context, SimpleChannelUser item) {
  //   RoomPersonalDataWidget.show(context, roomModel.channel, item);
  // }
}
